﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.SysManage
{
    public class T_PUB_SECURITY
    {
        private readonly DALL.SysManage.T_PUB_SECURITY dal = new DALL.SysManage.T_PUB_SECURITY();
        public T_PUB_SECURITY()
        { }
        #region  Method

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.SysManage.T_PUB_SECURITY model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.SysManage.T_PUB_SECURITY model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            return dal.Delete(ID);
        }
       

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SysManage.T_PUB_SECURITY GetModel(int ID)
        {

            return dal.GetModel(ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SysManage.T_PUB_SECURITY GetModel()
        {

            return dal.GetModel();
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysManage.T_PUB_SECURITY> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysManage.T_PUB_SECURITY> DataTableToList(DataTable dt)
        {
            List<Model.SysManage.T_PUB_SECURITY> modelList = new List<Model.SysManage.T_PUB_SECURITY>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.SysManage.T_PUB_SECURITY model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.SysManage.T_PUB_SECURITY();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["SECURITY"] != null && dt.Rows[n]["SECURITY"].ToString() != "")
                    {
                        model.SECURITY = dt.Rows[n]["SECURITY"].ToString();
                    }
                    if (dt.Rows[n]["PRODUCER_ID"] != null && dt.Rows[n]["PRODUCER_ID"].ToString() != "")
                    {
                        model.PRODUCER_ID = int.Parse(dt.Rows[n]["PRODUCER_ID"].ToString());
                    }
                    if (dt.Rows[n]["PRODUCER_NAME"] != null && dt.Rows[n]["PRODUCER_NAME"].ToString() != "")
                    {
                        model.PRODUCER_NAME = dt.Rows[n]["PRODUCER_NAME"].ToString();
                    }
                    if (dt.Rows[n]["PRODUCE_TIME"] != null && dt.Rows[n]["PRODUCE_TIME"].ToString() != "")
                    {
                        model.PRODUCE_TIME = DateTime.Parse(dt.Rows[n]["PRODUCE_TIME"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        #endregion  Method
    }
}
